<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        1.读取对象的属性值时:会自动到原型链中查找
        2.设置对象的属性值时:不会查找原型链,如粜当前对象中没有此属性,直接添加此属性并设置其值
        3.方法一般定义在原型中，属性一般通过构造函数定义在对象本身上

     -->
     <script>
        function Fn(){
            
        }
        Fn.prototype.a = 'xxx'
        var fn1 = new Fn()
        console.log(fn1.a,fn1);
        var fn2 = new Fn()
        fn2.a = 'yyy'
        console.log(fn1.a,fn2.a,fn2);

        function Person(name,age){
            this.name = name
            this.age = age
        }
        Person.prototype.setName = function (name){
            this.name = name
        }
        var p1 = new Person('Tom',12)
        p1.setName('Bob')
        console.log(p1);

        var p2 = new Person('Jack',12)
        p1.setName('Cat')
        console.log(p2);

        console.log(p1.__proto__ === p2.__proto__);  //true
        
     </script>
</body>
</html>